<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core">
    <h:body>
		<ui:composition template="./templates/framework.xhtml">
			<ui:define name="content">
				<ui:include src="./templates/header.xhtml">
					<ui:param name="text" value="#{i18n['generic.back']}" />
					<ui:param name="link" value="index.xhtml" />
				</ui:include>
				<h:form id="listSharesForm" styleClass="primary">
					<h:dataTable value="#{listSharesBean.shares}" var="share" styleClass="table shareList" rendered="#{not empty listSharesBean.shares}" binding="#{listSharesBean.dataTable}" columnClasses="nameColumn,accessColumn,rightColumn,deleteColumn">
						<h:column>
							<h:outputText value="#{share.user}" />
						</h:column>
						<h:column>
							<ui:fragment rendered="#{share.status eq 1}"><h:outputText value="#{i18n['share.confirmed']}" /></ui:fragment>
							<ui:fragment rendered="#{share.status eq 2}"><h:outputText value="#{i18n['share.invited']}" /></ui:fragment>
						</h:column>
						<h:column>
							<h:selectOneMenu id="accessRight" value="#{share.accessRight}" disabled="#{share.self}" styleClass="#{share.self ? 'transparent' : ''}">
								<f:selectItem itemLabel="#{i18n['share.readOnly']}" itemValue="READ_ONLY" />
								<f:selectItem itemLabel="#{i18n['share.readWrite']}" itemValue="READ_WRITE" />
								<f:selectItem itemLabel="#{i18n['share.owner']}" itemValue="OWNER" />
							</h:selectOneMenu>
						</h:column>
						<h:column>
							<ui:fragment rendered="#{!share.self}">
								<h:outputLink value="listshares.xhtml?delete=#{share.exposableId}" onclick="return confirm('#{i18n['share.removeConfirmation']}')" styleClass="deleteLink"></h:outputLink>
							</ui:fragment>
						</h:column>
					</h:dataTable>
					<div class="buttons">
						<ui:fragment rendered="#{sessionBean.getKeeBookAccess('OWNER')}">
							<h:commandButton type="submit" value="#{i18n['share.apply']}" action="#{listSharesBean.update}" styleClass="alignLeft" />
							<input type="button" value="#{i18n['share.invite']}" onclick="location.href='share.xhtml'" />
							<input type="button" value="#{i18n['generic.cancel']}" onclick="location.href='index.xhtml'" />
						</ui:fragment>
					</div>
				</h:form>
			</ui:define>
		</ui:composition>
    </h:body>
</html>